from langchain_core.tools import tool
from langgraph.prebuilt import create_react_agent
from langchain_ollama import ChatOllama

llm = ChatOllama(model="qwen3:8b", temperature=0.5, reasoning=False)

@tool(return_direct=True)
def greet(user_name: str) -> int:
    """Greet user."""
    return f"Hello {user_name}!"

tools = [greet]

agent = create_react_agent(
    model=llm.bind_tools(tools, tool_choice={"type": "tool", "name": "greet"}),
    tools=tools
)

result = agent.invoke(
    {"messages": [{"role": "user", "content": "Hi, I am Bob"}]}
)
print(result)